package com.hspedu.newData.dmsxl.双指针;
/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-09 
 * @Version: 1.0
 */

public class LC167两数之和Ⅱ输入有序数组 {

    public int[] twoSum(int[] numbers, int target) {

        int i = 0;
        int j = numbers.length - 1;

        int[] res = new int[2];
        while (i<j){

            int sum = numbers[i] + numbers[j];
            if (sum==target){
                break;
            } else if (sum > target) {
                j--;
            }else {
                i++;
            }

        }
        res[0] = i+1;
        res[1] = j+1;
        return res;
    }
}
